package structurepattern.composite;

import java.util.ArrayList;
import java.util.List;

public class ConcreteCompany extends Company {
	private List<Company> children = new ArrayList<Company>();
	
	public ConcreteCompany(String name) {
		super(name);
	}
	
	@Override
	public void add(Company company) {
		children.add(company);
	}

	@Override
	public void remove(Company company) {
		children.remove(company);
	}

	@Override
	public void display(int dept) {
		int tmp = dept;
		while(tmp -- > 0)
			System.out.print("-");
		System.out.println(name);
		
		for(Company component: children) {
			component.display(dept + 2);
		}
	}

	@Override
	public void lineOfDuty() {
		for(Company component: children) {
			component.lineOfDuty();
		}
	}
}
